import math

a = input()
b = a.split()

if b[0] == "zero":
    b1 = 0
elif b[0] == "one":
    b1 = 1
elif b[0] == "two":
    b1 = 2
elif b[0] == "three":
    b1 = 3
elif b[0] == "four":
    b1 = 4
elif b[0] == "five":
    b1 = 5
elif b[0] == "six":
    b1 = 6
elif b[0] == "seven":
    b1 = 7
elif b[0] == "eight":
    b1 = 8
elif b[0] == "nine":
    b1 = 9
else:
    print("Wrong input")
    exit(1)

if b[1] == "zero":
    b2 = 0
elif b[1] == "one":
    b2 = 1
elif b[1] == "two":
    b2 = 2
elif b[1] == "three":
    b2 = 3
elif b[1] == "four":
    b2 = 4
elif b[1] == "five":
    b2 = 5
elif b[1] == "six":
    b2 = 6
elif b[1] == "seven":
    b2 = 7
elif b[1] == "eight":
    b2 = 8
elif b[1] == "nine":
    b2 = 9
else:
    print("Wrong input")
    exit(1)

if b[2] == "zero":
    b3 = 0
elif b[2] == "one":
    b3 = 1
elif b[2] == "two":
    b3 = 2
elif b[2] == "three":
    b3 = 3
elif b[2] == "four":
    b3 = 4
elif b[2] == "five":
    b3 = 5
elif b[2] == "six":
    b3 = 6
elif b[2] == "seven":
    b3 = 7
elif b[2] == "eight":
    b3 = 8
elif b[2] == "nine":
    b3 = 9
else:
    print("Wrong input")
    exit(1)

d = int(str(b1) + str(b2) + str(b3))
g = 0
for i in range(2, int(d/2) + 1):
    if d % i == 0:
        g += 1
if g == 0:
    print(d)
else:
    i1 = d + 1
    while True:
        g = 0
        for i in range(2, int(i1/2) + 1):
            if i1 % i == 0:
                g += 1
        if g == 0:
            print(i1)
            break
        i1 += 1